<template>
	<view class="home">
		<view class="activebg position-relative">
			<ty-swiper-home :list="carousel" height='360' radius='50'></ty-swiper-home>
			<view class="gzbg" @click="go('/pages/game/rule')">兑换规则</view>
		</view>
		<view class="flex justify-between flex-wrap margin-top-50">
			<view class="width-330 bg-ff radius-40 margin-bottom-40"
				style="box-shadow: 0rpx 16rpx 80rpx 0rpx rgba(176,181,185,0.25);" v-for="(item,index) in list" :key="index"
				@click="go('/pages/game/shopdetail?id='+item.id)">
				<image :src="item.image" mode="" class="gameimg"></image>
				<view class="padding-tb-20 padding-lr-30">
					<view class="text-cut-one text-28 text-bold">{{item.product_name}}</view>
					<view class="flex align-center margin-top-15">
						<image src="/static/board/money.png" mode="" class="moneyimg"></image>
						<view class="text-28 text-66 flex-one margin-left-5">{{item.price}}</view>
						<view class="dhbtn" v-if="item.is_buy==1">立即兑换</view>
						<view class="bzbtn" v-else>妖币不足</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				last_page: 0,
				current_page: 1,
				carousel: [{
					image: '/static/board/member.png'
				}, {
					image: '/static/board/member.png'
				}]
			}
		},
		onLoad() {
			this.init()
			this.rq.getData('common/banner', {
				type: 4
			}).then(res => {
				if (res.code == 1) {
					this.carousel = res.data
				}
			})
		},
		onReachBottom() {
			if(this.list!=undefined&&this.list.length>0){
				this.current_page++
				if (this.last_page<this.current_page) {
					return
				}
				this.init()
			}
		},
		methods: {
			init() {
				var that = this
				that.rq.getData('sign/ScoreProducts', {
					page:this.current_page
				}).then(res=>{
					if(res.code==1){
						let list = res.data.data
						this.last_page = res.data.last_page;
						this.current_page = res.data.current_page;
						if (this.current_page==1) {
							this.list=list
						} else {
							if(list.length>0){
								this.list=this.list.concat(list)
							}
						}
					}
				})
			}
		}
	}
</script>

<style>
	.home {
		width: 100%;
		min-height: 100vh;
		background: #fff;
		padding: 40rpx 30rpx;
	}

	.gzbg {
		width: 54rpx;
		/* height: 156rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 8rpx 8rpx 0rpx rgba(0, 0, 0, 0.25);
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		white-space: pre-wrap;
		padding: 20rpx 15rpx;
		text-align: center;
		position: absolute;
		right: 0;
		top: 102rpx;
	}

	.gameimg {
		width: 330rpx;
		height: 278rpx;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
	}
	.moneyimg{
		width: 24rpx;
		height: 24rpx;
	}
	.dhbtn{
		width: 160rpx;
		height: 60rpx;
		background: #101010;
		border-radius: 200rpx 200rpx 200rpx 200rpx;
		font-weight: bold;
		font-size: 28rpx;
		color: #FFFFFF;
		line-height: 60rpx;
		text-align: center;
	}
	.bzbtn{
		width: 160rpx;
		height: 60rpx;
		background: #E5E5E5;
		border-radius: 200rpx 200rpx 200rpx 200rpx;
		font-weight: bold;
		font-size: 28rpx;
		color: #000;
		line-height: 60rpx;
		text-align: center;
	}
</style>